[iOS] Fix issue that does not allow scrolling in WebView with PDF#21571
[iOS] Fix issue that does not allow scrolling in WebView with PDF#21571jsuarezruiz wants to merge 10 commits into
Conversation
| } | ||
|
|
||
| if (!result.UserInteractionEnabled) | ||
| if (Descendants is not null && Descendants.Contains(result) && !result.UserInteractionEnabled) |
There was a problem hiding this comment.
Here, the HitTest result could be an element of the hierarchy, but we are really only interested in elements of the hierarchy that come from Handlers, that is, those native elements created from an abstraction and that inherit from View and can use the InputTransparent property.
In the case of the WebView, the first element was _UIRemoteView with UserInteractionEnabled equals to false. This blocked interaction with the WebView. With the changes, we only verify elements added as children of the Layout, in the example added in this PR, it would only be a single WKWebView element, our WebView that is not disabled nor does use InputTransparent.
| <Grid> | ||
| <WebView | ||
| x:Name="WaitForStubControl" | ||
| Source="https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_1MB_PDF.pdf"> |
There was a problem hiding this comment.
I think it's better to maybe add a local pdf that would make sure we don't hit any connection issues loading this
There was a problem hiding this comment.
Yeah, we can maybe at least host the pdf in the maui repo since we cannot control what this pdf is/does in the future.
mattleibow
left a comment
There was a problem hiding this comment.
Looks good. Just a few nit comments.
| { | ||
| this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); | ||
|
|
||
| await Task.Delay(1000); // Wait WebView to load. |
There was a problem hiding this comment.
This this gets flakey, we can have the webview page loaded event update some label and we can wait for that.
There was a problem hiding this comment.
Updated waiting a Label text after navigated.
| <Grid> | ||
| <WebView | ||
| x:Name="WaitForStubControl" | ||
| Source="https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_1MB_PDF.pdf"> |
There was a problem hiding this comment.
Yeah, we can maybe at least host the pdf in the maui repo since we cannot control what this pdf is/does in the future.
| [Category(UITestCategories.WebView)] | ||
| public async Task CanScrollWebView() | ||
| { | ||
| this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows }); |
There was a problem hiding this comment.
Would this be worth enabling for all platforms?
There was a problem hiding this comment.
Enabled on more platforms. Scrolling using gestures, so Android and iOS.
| } | ||
|
|
||
| if (!result.UserInteractionEnabled) | ||
| if (Subviews.Contains(result) && !result.UserInteractionEnabled) |
There was a problem hiding this comment.
Would it be better to rather do result.Superview == this instead of getting the subviews array and looping through them all?
There was a problem hiding this comment.
Also, I am thinking we can't just check the result, we need to find the parent that is the child of the layout. So I am thinking:
while (result.Superview is not null && result.Superview != this)
result = result.Superview;
if (result.Superview == this && !result.UserInteractionEnabled)If we have a secret scroll view in our webview, we still need to find that webview and read the property the user set in XAML.
|
What happens when the dev sets the webview as input transparent? can you scroll? what does the hit test result become? I cannot recall if the user interaction value is "viral" and the hit test blocks hitting all children. |
|
/rebase |
a8cd21e to
91a0b14
Compare
|
Alternative PR #21883 |
|
Closing in favor of |

Description of Change
Fix issue that does not allow scrolling in WebView with PDF on iOS.
Initially, I started by checking the status of the WebView: if internal UIScrollView scrolling was enabled, if the assigned size was correct, etc. Everything is fine so let's go check the hierarchy. It was interesting that the problem does not appear without a Layout as a parent. Reviewing I realized that the problem comes from the changes applied in #17286 related to InputTransparent. Applied changes to keep the InputTransparent working and fix the issue.
Issues Fixed
Fixes #18716